import { createApp,ref } from 'vue'
import ElementPlus from 'element-plus'
import VueUeditorWrap from 'vue-ueditor-wrap';
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import en from 'element-plus/es/locale/lang/en'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'

import { createPinia } from 'pinia'
const pinia = createPinia()

import App from '@/App.vue'
import router from '@/common/router.js'
import Api from '@/common/http.js'

import {I18n,lang} from "@/lang/index"; //引入i18n组件

//控制 element-plus 组件语言
let locale = '';
if(I18n.global.fallbackLocale == 'zh') {
    locale = zhCn;
} else {
    locale = en;
}

const app = createApp(App);

//定义全局方法
app.provide('api',Api);

//定义全局方法
app.config.globalProperties.$l = lang;

// 使用全局方法
// import { getCurrentInstance } from 'vue'
// const { proxy } = getCurrentInstance(); //获取上下文实例，ctx=vue2的this
// onMounted(() => {
// 	console.log(proxy)
// 	console.log(proxy.$l('超人','menu.t1'))
// });


//定义全局组件
import anNav from "@/components/anNav.vue";
app.component('anNav',anNav)

app.use(ElementPlus, {
    locale,
})
app.use(pinia)
app.use(I18n)
app.use(VueUeditorWrap)
app.use(router).mount('#app')

